//vector.cpp

#include "vector.h"

//---Vector
Vector::Vector(unchar* newValues, int newSize)
{
	values=0;
	set(newValues, newSize);
}
Vector::~Vector()
{
	values=0;
	set(0, 0);
}	
int Vector::operator==(Vector* vec)
{
	if(size!=vec->size)
		return 0;
	for(int i=0; i<size; ++i)
	{
		if(values[i]-vec->values[i]!=0)
			return 0;
	}
	return 1;
}
void Vector::set(unchar* newValues, int newSize)
{
	delete[] values;
	values=0;
	size=0;
	if(newSize==0)
		return;
	size=newSize;
	values = new unchar[size];
	for(int i=0; i<size; ++i)
		values[i]=newValues[i];
}
void Vector::set(Vector* vec)
{
	set(vec->getValues(), vec->getSize());	
}	
void Vector::add(unchar* newValues, int newSize)
{
	unchar* buff = new unchar[size+newSize];
	for(int i=0; i<size; ++i)
		buff[i]=values[i];
	for(int i=0; i<newSize; ++i)
		buff[i+size]=newValues[i];
	delete[] values;
	values=buff;
	size+=newSize;
}
void Vector::add(Vector* vec)
{
	add(vec->getValues(), vec->getSize());	
}	
